home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 4 / CU Amiga Magazine's Super CD-ROM 04 (1996)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1996-11].iso / magazine / psion / apps2 / ascii.lzx / ascii.opl next >
Text File  |  2019-06-04  |  3KB  |  171 lines

  1. REM ASCII table utility for Series 3.
  2. REM Rick Andrews Dec 91
  3.  
  4.  
  5. PROC Ascii:
  6. REM Main routine.
  7.     LOCAL Width%(4) REM Screen widths for each mode.
  8.     LOCAL g%,Mode%,TopChar%,c%
  9.     LOCAL Exit%,Line%
  10.     LOCAL Char&, Char$(1)
  11.  
  12.     Exit%=0
  13.     TopChar%=%A
  14.     Mode%=4 REM Dec+Hex+Char.
  15.     Width%(1)=20 REM Char only.
  16.     Width%(2)=8 REM Hex+Char.
  17.     Width%(3)=6 REM Dec+Char.
  18.     Width%(4)=4 REM Dec+Hex+Char.
  19.     CLS
  20.  
  21. REM Only switch gUPDATE off when you
  22. REM have finished testing the program.
  23.     gUPDATE OFF
  24.  
  25.     DO
  26.         c%=TopChar%
  27.         Line%=1
  28.         DO
  29.             AT 1,Line%
  30.             c%=DispASC%:(c%,Mode%,Width%(Mode%))
  31.             Line%=Line%+1
  32.         UNTIL Line%>9
  33.         g%=GET
  34.  
  35. REM Test for Menu or hot-key.
  36.         IF g%=$122 OR (g% AND $200)
  37.             IF g%=$122 REM Menu.
  38.                 mINIT
  39.                 mCARD "Mode","Char only",%C,"Hex & char",%H,"Dec & char",%D,"All three",%A,"Exit",%X
  40.                 mCARD "Position","At char 0",%Z,"Enter number",%N,"Enter char",%R
  41.                 mCARD "Key","Show keypress",%K
  42.                 g%=MENU
  43.             ELSE REM Must be hot-key.
  44.                 g%=(g%-$200)
  45.             ENDIF
  46.             g%=g% AND $FFDF
  47.  
  48.             IF g%=%C REM Char only.
  49.                 Mode%=1 :CLS
  50.             ELSEIF g%=%H REM Hex and char.
  51.                 Mode%=2 :CLS
  52.             ELSEIF g%=%D REM Decimal and char.
  53.                 Mode%=3 :CLS
  54.             ELSEIF g%=%A REM All three.
  55.                 Mode%=4 :CLS
  56.             ELSEIF g%=%X REM Exit.
  57.                 Exit%=-1
  58.             ELSEIF g%=%Z REM to char Zero.
  59.                 TopChar%=0
  60.             ELSEIF g%=%N
  61.                 Char&=TopChar%
  62.                 dINIT "Position"
  63.                 dLONG Char&,"Number",0,255
  64.                 IF DIALOG
  65.                     TopChar%=Char&
  66.                 ENDIF
  67.             ELSEIF g%=%R
  68.                 dINIT "Position"
  69.                 dEDIT Char$,"Char"
  70.                 IF DIALOG
  71.                     TopChar%=ASC(Char$)
  72.                 ENDIF
  73.             ELSEIF g%=%K
  74.                 KeyPress:
  75.             ENDIF
  76.  
  77. REM Test for non hot-keys.
  78.         ELSEIF g%=27 REM Esc
  79.             Exit%=-1
  80.         ELSEIF g%=256 REM Up
  81.             TopChar%=TopChar%-Width%(Mode%)
  82.         ELSEIF g%=257 REM Down
  83.             TopChar%=TopChar%+Width%(Mode%)
  84.         ELSEIF g%=260 REM Pg Up
  85.             TopChar%=TopChar%-(9*Width%(Mode%))
  86.         ELSEIF g%=261 REM Pg Dn
  87.             TopChar%=TopChar%+(9*Width%(Mode%))
  88.         ENDIF
  89.  
  90. REM Handle wraparound.
  91.         IF TopChar%>255
  92.             TopChar%=TopChar%-256
  93.         ELSEIF TopChar%<0
  94.             TopChar%=TopChar%+256
  95.         ENDIF
  96.  
  97.     UNTIL Exit%
  98.     gUPDATE ON
  99. ENDP
  100.  
  101.  
  102. PROC DispASC%:(FromC%,Mode%,Wid%)
  103. REM Show ASCII table from char FromC%,
  104. REM in mode Mode%, with Wid% chars
  105. REM per screen line.
  106. REM Return next char position.
  107.  
  108.     LOCAL i%,Char%,Sep$(1)
  109.  
  110.     Sep$=CHR$(254) REM Seperator.
  111.     Char%=FromC%
  112.     DO
  113.  
  114.         IF Mode%=2 REM Hex+char.
  115.             PRINT RIGHT$("0"+HEX$(Char%),2);sep$;
  116.  
  117.         ELSEIF Mode%=3 REM Dec+char.
  118.             PRINT GEN$(Char%,-3);sep$;
  119.  
  120.         ELSEIF Mode%=4 REM all.
  121.             PRINT GEN$(Char%,-3);sep$;
  122.             PRINT RIGHT$("0"+HEX$(Char%),2);sep$;
  123.         ENDIF
  124.  
  125. REM All modes print a char.
  126. REM Skip unprintable chars.
  127.         IF ( (Char%>=7 AND Char%<=13) OR Char%=255)
  128.             PRINT ".",
  129.         ELSE
  130.             PRINT CHR$(Char%),
  131.         ENDIF
  132.  
  133.         i%=i%+1
  134.         Char%=Char%+1
  135.         IF Char%>255
  136.             Char%=0
  137.         ENDIF
  138.     UNTIL i%>=Wid%
  139.     RETURN Char%
  140. ENDP
  141.  
  142.  
  143. PROC KeyPress:
  144. REM Display ASCII code of keypress,
  145. REM also KMOD modifiers.
  146.  
  147.     LOCAL g%,k%
  148.     CLS
  149.     PRINT "Press any key (ESC to exit)"
  150.     PRINT "Key code & Key modifier"
  151.     DO
  152.         g%=GET
  153.         k%=KMOD
  154.         PRINT g%,k%,
  155.         IF k% AND 2
  156.             PRINT "Shift",
  157.         ENDIF
  158.         IF k% AND 4
  159.             PRINT "Control",
  160.         ENDIF
  161.         IF k% AND 8
  162.             PRINT CHR$(2);"Key", REM Psion symbol.
  163.         ENDIF
  164.         IF k% AND 16
  165.             PRINT "CapsLock",
  166.         ENDIF
  167.         PRINT
  168.     UNTIL g%=27 REM Esc.
  169.     RETURN
  170. ENDP
  171.